import threading
import time

g_num=10
g_list=[1,2,3]

def work1():
    global g_num
    for i in range(10):
        g_num+=1

    print('全局变量在work1中的值为{}'.format(g_num))#20


def work2():
    global g_num
    print('全局变量在work2中的值为{}'.format(g_num))#20


def work3():
    for i in range(4,7):
        g_list.append(i)
    print('列表在work3中为{}'.format(g_list))#[1,2,3,4,5,6]


def work4():
    print('列表在work4中为{}'.format(g_list))#[1,2,3,4,5,6,]


if __name__ == '__main__':
    t1=threading.Thread(target=work1)
    t2=threading.Thread(target=work2)
    t1.start()
    t2.start()
    print(g_num)#20
    t3 = threading.Thread(target=work3)
    t4 = threading.Thread(target=work4)
    t3.start()
    t4.start()
    print(g_list)# [1,2,3,4,5,6]